README FOR QUANTITATIVE ANALYSIS

This folder contains the code to calibrate the quantitative model as described in Section 4 and generate the results described in Section 5. The code is organized into three subfolders:
- Data: contains datatables in Stata format with the inputs to the calibration exercise.
- Model: contains the C code to calibrate the model's parameters and produce the output underlying the figures in the paper.
- Scripts: contains Python code that processes the inputs and model output to create figures, tables, and other numbers cited in the paper.

Main requirements:
- Python 3+, including Numpy, Scipy, Matplotlib, Statsmodels, and Seaborn libraries.
- C compiler, plus GSL and OpenMP libraries.
Please be aware that the code to run the model is highly parallelizaed and requires a computer with a large number of codes to run in a reasonable amount of time (I used a 128-core AMD-based workstation.) All code was run in Ubuntu Linux. Commands below in quotes illustrate how to execute the different parts of the code in a Unix-based environment. Contact Joseph Steinberg (joseph.steinberg@utoronto.ca) for help running the code on other systems.

To re-process the inputs from the empirical part of the paper, navigate to the scripts folder and type "python3 prep_data.py".

To reproduce the figures and tables, navigate to the scripts folder and type "python3 paper_figs.py". Please note that all of the output generated by the model that goes into these figures is contained in the replication pcakage; the user can run this script without re-running the model code first.

The compile the model code, navigate to the model folder type "make".

To run the baseline model using the calibrated parameters and re-generate the output used to make the figures, navigate to the model folder and type "./bin/model_jpe_final".

The model has several command-line arguments that allow the user to recalibrate the parameters and run sensitivity analyses:
-cal-exporter-params: re-calibrates the exporter-dynamics parameters as described in Section 4.3
-cal-probs: re-calibrate the trade-policy transition probabilities as described in Section 4.4
-PS-1980-temp: model with constant TPU from 1980 onward (use in conjunction with -cal-probs)
-PS-1990-temp: model with constant TPU from 1990 onward (use in conjunction with -cal-probs)
-perm-tpu: model with unanticipated changes in policy transition matrix (use in conjunction with -cal-probs)
-one-sector: model with only one sector (use in conjuction with cal-exporter-params and cal-probs)
-calvo: fast-adjustment model without exporter life-cycle dynamics (use in conjuction with cal-exporter-params and cal-probs)
-ci-lower: target lower CI of NTR-gap elasticity estimate instead of point estimate (use with cal-probs)
-ci-higher: target lower CI of NTR-gap elasticity estimate instead of point estimate (use with cal-probs)
-lo-xi: smaller differences between low and high capacity exporters (use with cal-probs)
-hi-xi: larger differences between low and high capacity exporters (use with cal-probs)
-lo-rhoxi: lower iceberg trade cost persistence (use with cal-probs)
-hi-rhoxi: higher iceberg trade cost persistence (use with cal-probs)
-AGS-sens: compute Jacobian matrix of NTR-gap elasticities to transition probabilities
Note that -cal-exporter-params and -cal-probs use baseline estimates as initial guesses and therefore converge immediately, but code can easily be modified to start from naive initial guesses.



